<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@taglib prefix="fnc" uri="http://samplefn" %>
<s:layout-render name="/layout_template.jsp" nadpis="vehicle.detailsHeading">
    <s:layout-component name="telo">
        <div id="form">
        <div id="formtitle"><f:message key="vehicle.identification"/></div>                  
        <div class="row"><span class="col1">ID:&nbsp;</span><span class="col2"><c:out value="${actionBean.vehicle.id}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.makerForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.carProducer}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.modelForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.carModel}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.yearForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.yearOfManufacture}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.engineForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.engineType}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.vinForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.vin}"/></span></div>
        <div class="row"><span class="col1"><f:message key="vehicle.licensePlateForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.stateLicencePlate}"/></span></div>
        <div id="formtitle" class="row"><f:message key="vehicle.driavenStatus"/></div>   
        <div class="row"><span class="col1"><f:message key="vehicle.numberKmForm"/></span><span class="col2"><c:out value="${actionBean.vehicle.numberOfKms}"/></span></div> 
        <div class="row"><span class="col1"><f:message key="vehicle.statusForm"/></span><span class="col2"><f:message key="VehicleStatus.${actionBean.vehicle.status}"/></span></div>  
        <div class="row"><span class="col1"><f:message key="vehicle.availibleForForm"/></span><span class="col2"><f:message key="EmployeePosition.${actionBean.vehicle.availableForPositions}"/></span></div> 
        </div>
        <div style="margin-top: 430px"> <f:message key="vehicle.checks"/> 
        <c:out value="${actionBean.vehicle.carProducer} ${actionBean.vehicle.carModel} ${actionBean.vehicle.engineType} >> ${actionBean.vehicle.numberOfKms} Km"/> 
        </div>
        <table id="basicview">
            <thead>
                <tr>
                    <th><f:message key="id"/></th>
                    <th><f:message key="serviceCheck.date"/></th>
                    <th><f:message key="serviceCheck.checkPurpose"/></th>
                    <th><f:message key="serviceCheck.checkInterval"/></th>
                    <th><f:message key="serviceCheck.isActive"/></th>
                    <th><f:message key="serviceCheck.checkDone"/></th>
                    <th><f:message key="serviceCheck.toBeDone"/></th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${actionBean.vehicle.controlServiceCheck}" var="servicecheck" varStatus="loop">
                    <tr>
                        <td>${servicecheck.id}</td>
                        <c:if test="${!empty servicecheck.dateOfCheck}">
                            <f:message key="dateFormatForm" var="checkDate" />
                            <f:formatDate value="${servicecheck.dateOfCheck}" pattern="${checkDate}" var="checkdatevar" />
                             <td><c:out value="${checkdatevar}" /></td>
                        </c:if>
                        <c:if test="${empty servicecheck.dateOfCheck}">
                            <td><c:out value="---"/></td>
                        </c:if>
                        <td><c:out value="${servicecheck.checkPurpose}"/></td>
                        <td><c:out value="${servicecheck.checkInterval}"/></td>
                        <c:if test="${servicecheck.isActive}">
                            <td><b><font style="color: red"><f:message key="${servicecheck.isActive}"/></b></td>
                        </c:if>
                        <c:if test="${!servicecheck.isActive}">
                            <td><f:message key="${servicecheck.isActive}"/></td>
                        </c:if>
                        <td><f:message key="${servicecheck.checkDone}"/></td>
                        <c:if test="${servicecheck.checkDone}">
                            <td><c:out value="${servicecheck.lastCheck}"/></td>
                        </c:if>
                        <c:if test="${!servicecheck.checkDone}">
                            <c:set var="pom" value="${servicecheck.checkInterval}"/>
                            <td><c:out value="${servicecheck.lastCheck + pom}"/></td>
                        </c:if> 
                    </tr>
                </c:forEach>
            </tbody>
            </table>
                <br>
        <s:link class="button" beanclass="cz.muni.fi.pa165.carparkweb.actionbeans.VehicleActionBean" event="storno"><f:message key="back"/></s:link>
        
    </s:layout-component>
</s:layout-render>


